from math import sqrt
import numpy as np
uplimit = 1500000

M_limit = int(sqrt(uplimit/2))+1
res_dict = {}
for m in range(1,M_limit):
    for n in range(1,m):
        a = m**2 - n**2
        b = 2*m*n
        c = m**2 + n**2
        l = a + b + c
        if l >  uplimit:
            continue
        tmp_1 = np.array(sorted((a,b,c)))
        k = l
        tms = tmp_1.copy()
        while k <= uplimit:
            if k in res_dict:
                tmp_2 = res_dict[k]["xl"]
                tmp_nums = res_dict[k]["sl"]
                if all(tmp_1!=tmp_2):
                    res_dict[k]["sl"] = 0
                    break
            else:
                res_dict[k]={"xl":tmp_1,"sl":1}
            k = k + l
            tmp_1 = tmp_1 + tms

counts = 0
for k,v in res_dict.items():
    counts += v["sl"]
    print(v["xl"])
    print(v["sl"])

print(counts)